package org.carabiner.util;

import java.awt.Component;

/**
 * Contains utility methods for Swing/AWT components.
 * 
 * <p>
 * Carabiner Testing Framework
 * </p>
 * 
 * <p>
 * Copyright: <a href="http://www.gnu.org/licenses/gpl.html">GNU Public License</a>
 * </p>
 * 
 * @author Ben Rady (benrady@gmail.com)
 */
public class ComponentUtils
{
  private ComponentUtils()
  {
  }

  /**
   * Gets either the name of the component, if it is defined. Otherwise it
   * returns the fully qualified classname.
   * 
   * @param component
   *          Component
   * @return String
   */
  public static String getComponentName(Component component)
  {
    if (component.getName() == null)
      return component.getClass().toString();
    else
      return component.getName();
  }
}
